VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsValidation"
Attribute VB_GlobalNameSpace = True
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'xwelx 04.2010

Option Explicit

Public Function ValidKeys(KeyIn As Integer, ValidateString As String, Editable As Boolean) As Integer

'ex:  KeyAscii = ValidKeys(KeyAscii, "01234567890.", True)
Dim ValidateList As String
Dim KeyOut As Integer

    If KeyIn = 13 Then Exit Function
    
    If Editable = True Then
        ValidateList = UCase(ValidateString) & Chr(8)
    Else
        ValidateList = UCase(ValidateString)
    End If
    
    If InStr(1, ValidateList, UCase(Chr(KeyIn)), 1) > 0 Then
        KeyOut = KeyIn
    Else
        KeyOut = 0
        Beep
    End If
    
    ValidKeys = KeyOut
End Function

Public Function InvalidKeys(KeyAscii As Integer, varStr As String) As Integer
    If varStr Like ("*" & Chr(KeyAscii) & "*") Then
        InvalidKeys = 0
    Else: InvalidKeys = KeyAscii
    End If
End Function

'Sends the cursor to the next tab stop
Public Sub SendKeysTab(Key As Integer)
    If Key = 13 Then SendKeys "{Tab}"
End Sub



'Audit trail function
Function UpdateLogFile(cModule As String, cTranNo As String, cEvent As String)
On Error Resume Next
Dim oDB As New clsConnection
Dim oString As New clsDeclaration
Dim LogCmd As ADODB.Command
Set LogCmd = New ADODB.Command

    With LogCmd
        Set .ActiveConnection = oDB.cn
        .CommandText = "AuditTrail"
        .CommandType = adCmdStoredProc
        .Parameters.Refresh
    End With
    LogCmd.Parameters("@cModule") = LTrim(RTrim(cModule))
    LogCmd.Parameters("@cTranNo") = LTrim(RTrim(cTranNo))
    LogCmd.Parameters("@cEvent") = LTrim(RTrim(cEvent))
    LogCmd.Parameters("@cUser") = LTrim(RTrim(oString.SecUserID))
    LogCmd.Parameters("@cCompanyID") = LTrim(RTrim(oString.COID))
    LogCmd.Execute
    Set LogCmd.ActiveConnection = Nothing
    Set oString = Nothing
    Set oDB = Nothing
End Function

'Gl Activity
Public Function UpdateGLA(cEvent As String, cModule As String, cTranNo As String)
On Error Resume Next
Dim oDB As New clsConnection
Dim oString As New clsDeclaration
Dim LogCmd As ADODB.Command
Set LogCmd = New ADODB.Command


    With LogCmd
        Set .ActiveConnection = oDB.cn
        If cEvent = "Update" Then
            .CommandText = "USP_UpdateGL"
        Else: .CommandText = "USP_DeleteGL"
        End If
        .CommandType = adCmdStoredProc
        .Parameters.Refresh
    End With
    LogCmd.Parameters("@cCompanyID") = LTrim(RTrim(oString.COID))
    LogCmd.Parameters("@cModule") = LTrim(RTrim(cModule))
    LogCmd.Parameters("@cTranNo") = LTrim(RTrim(cTranNo))
    
    LogCmd.Execute
    Set LogCmd.ActiveConnection = Nothing
    Set oString = Nothing
    Set oDB = Nothing
    
End Function

'FixedLength
Public Function FixedLength(KeyAscii As Integer, sText As String, nLength As Long) As Integer
    If KeyAscii = vbKeyReturn Then
        FixedLength = KeyAscii
    ElseIf KeyAscii = vbKeyDelete Then
        FixedLength = KeyAscii
    ElseIf KeyAscii = vbKeyBack Then
        FixedLength = KeyAscii
    ElseIf Len(sText) = nLength Then
        Beep
        FixedLength = 0
    Else
        FixedLength = KeyAscii
    End If
End Function


